package com.supermap.application.dao;

import com.supermap.application.entity.TIndexSys;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 需继承对应实体类的 JpaRepository
 * 目标体系dao
 */
@Repository
public interface TargetManageIndexSysDao extends JpaRepository<TIndexSys,String> {

    //根据时间查询所有目标体系
    @Query("select t from TIndexSys t where t.name is not null and t.year = :year")
    List<TIndexSys> findAlL(@Param("year") String year);

    //根据目标体系名称查询体系编码
    @Query("select t from TIndexSys t where t.name = :name")
    TIndexSys findCodeByName(@Param("name") String name);

    //根据年份、目标体系名称、体系编码查询指标体系
    @Query("select t from TIndexSys t where t.year = :year and t.name = :name and t.code = :code")
    TIndexSys findOneByYearAndName(@Param("year") String year, @Param("name") String name, @Param("code") String code);

    @Query("select t from TIndexSys t where t.code = :code")
    TIndexSys findByCode(@Param("code") String code);
}
